package com.retallife.admin.controller;

import com.retallife.admin.exception.Result;
import com.retallife.admin.pojo.Goods.GoodsUpdateVo;
import com.retallife.admin.pojo.Goods.GoodsVo;
import com.retallife.admin.service.Goods.GoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@Api(tags = "商品信息类")
@RequestMapping(method = {RequestMethod.POST, RequestMethod.GET})
public class AdminGoodsController {

    @Autowired
    GoodsService goodsService;

    @ApiOperation(value = "查询商品表中的所有信息")
    @RequestMapping("AdminFindAllGoods")
    public List<GoodsVo> AdminFindAllGoods() {
        return goodsService.AdminFindAllGoods();
    }

    @ApiOperation(value = "审核商品")
    @RequestMapping("AdminUpdateGoods")
    public Result AdminUpdateGoods(@RequestBody GoodsUpdateVo goodsUpdateVo) {
        int result = goodsService.AdminUpdateGoods(goodsUpdateVo);
        if (result > 0) {
            return Result.ok("审核通过");
        }
        return Result.ok("审核未通过");
    }
}
